package com.bjqg.bjqg01.bjqg.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;

import com.bjqg.bjqg01.bjqg.R;
import com.bjqg.bjqg01.bjqg.bean.HomeBean;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.util.MultiTypeDelegate;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/1/5.
 */

public class HomeAdapter extends BaseQuickAdapter<HomeBean,BaseViewHolder> {


    public HomeAdapter(ArrayList<HomeBean> homeBeans){
        super(null);
        //Step.1
        setNewData(homeBeans);
        setMultiTypeDelegate(new MultiTypeDelegate<HomeBean>() {
            @Override
            protected int getItemType(HomeBean entity) {
                //根据你的实体类来判断布局类型
                return entity.type;
            }
        });
        getMultiTypeDelegate()
                .registerItemType(1, R.layout.item_more1_activity_home)
                .registerItemType(2, R.layout.item_more2_activity_home);
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeBean item) {
        //Step.3
        switch (helper.getItemViewType()) {
            case 1:
                // do something
                helper.setText(R.id.more1_title_name,item.getTitle().toString());
                break;
            case 2:
                // do something
                helper.setText(R.id.more2_title_name,item.getTitle().toString());
                break;
        }
    }
}
